// ex7_12_8.cpp
#include <iostream>

int replace(char *str, char c1, char c2);
int main(void)
{
	char arr[] = "howareyou";
	int count;
	std::cout << arr << std::endl;
	count = replace(arr, 'o','k');
	std::cout << arr << std::endl;
	std::cout << "count = " << count << std::endl;
}

int replace(char *str, char c1, char c2)
{
	char *ptr = str;
	int cnt = 0;
	while (*ptr++ != '\0')
	{
		if (*ptr == c1)
		{	
			*ptr = c2;
			cnt++;
		}
	}
	
	return cnt;	
}
